#include <iostream>
#include<Windows.h>
#include <conio.h>
using namespace std;

LONG dw = 0;

DWORD WINAPI Thread1(LPVOID param){
	
	dw ++;
	//InterlockedIncrement(&dw);
	/*InterlockedExchange(&dw, 3);
	InterlockedIncrement(&dw);*/
	cout << "In Thread1; dw = " << dw << endl;
	return 0;
}

void main(){

	cout << "In main; dw = " << dw << endl;
	char x;
	CreateThread(NULL, 0, Thread1, NULL, NULL, NULL);

	cout << "In main, after thread; dw = " << dw << endl;
	while( x = _getch(), x != 'y' )
	{
		cout << "In main, after thread; dw = " << dw << endl;
	}
	//_getch();
}